<template>
  <div>
    <div class="head">消息</div>
    <div v-if="chatUserList.length != 0">
      <div
        v-for="item in chatUserList"
        :key="item.userID"
        class="userStrip"
        @click="handleChat(item)"
      >
        <img :src="item.avator" width="50px" height="50px" />
        <p class="nickname">{{ item.nickname }}</p>
      </div>
    </div>
    <div v-else>
      <p style="line-height: 30px; color: #b5b5b5">
        你还没有聊天对象，快去找一个吧
      </p>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {};
  },
  methods: {
    handleChat(user) {
      this.$router.push({
        path: "/chatroom",
        query: {
          userID: user.userID,
          name: user.nickname,
          avator: user.avator,
        },
      });
    },
  },
  computed: {
    ...mapState(["chatUserList"]),
  },
};
</script>

<style scoped>
.head {
  font-size: 18px;
  padding: 10px 0;
  font-weight: bold;
  background-color: #FAFAFA;
}
.userStrip {
  display: flex;
  align-items: center;
  justify-content:flex-start;
  font-weight: bold;
  color: #0b1994;
  border-bottom: 1px solid #FAFAFA;
  padding: 5px 10px;
}
.nickname {
  margin: 10px;
  font-size: 20px;
}
</style>